home *** CD-ROM | disk | FTP | other *** search
- #define __FPATH_H
-
-
- #ifndef __IO_H
- #include "io.h"
- #endif
- #ifndef __DOS_H
- #include "dos.h"
- #endif
- #ifndef __STRING_H
- #include "string.h"
- #endif
- #ifndef __DSTRING_H
- #include "dstring.h"
- #endif
-
-
- #undef enable /* we don't need the macro enable & disable in dos.h */
-
- #undef disable
-
-
- #ifdef _MSC_VER /* microsoft */
- #undef isborland
- #else /* borland */
- #define isborland
- #endif
-
-
- #ifdef isborland /* we need MAXPATH and etc and rmdir */
-
- #ifndef __DIR_H
- #include "dir.h"
- #endif
-
- #else
-
- #ifndef __DIRECT_H
- #include "direct.h"
- #endif
-
- #ifndef __STDLIB_H
- #include "stdlib.h"
- #endif
-
- #define MAXPATH _MAX_PATH
- #define MAXDRIVE _MAX_DRIVE
- #define MAXDIR _MAX_DIR
- #define MAXFILE _MAX_FNAME
- #define MAXEXT _MAX_EXT
-
- #endif
-
-
- struct ffbuf:public WIN32_FIND_DATA
- {
- HANDLE h;
- };
-
- typedef unsigned int UINT;
-
-
- class varpath;
-
-
- class abspath /* abstract path */
- {
- public:
-
- enum
- {
- maxpath = MAXPATH, maxdrive = MAXDRIVE, maxdir = MAXDIR,
- maxfile = MAXFILE, maxext = MAXEXT
- };
-
- virtual char *getbuf() = 0;
-
- operator char*()
- {
- return getbuf();
- }
- char operator[](int i)
- {
- return getbuf()[i];
- }
- int del();
- int chdir();
- int mkdir();
- int rmdir();
- int chkdll();
- int chsize(long l);
- int access(int amode);
- int rename(abspath &x);
- int chkroot();
- int chkexist();
- int chkcanwrite();
- int chkdiroccupied();
- int multimkdir();
- int getdad(varpath *dad);
- int getr(varpath *r);
- int getd(varpath *d);
- int getf(varpath *f);
- int tostd(varpath *path);
- int gettime(SYSTEMTIME *ft);
- int settime(SYSTEMTIME &ft);
- int chksame(abspath &x);
- int comparetime(abspath &y);
- int setfileattr(DWORD flags);
- int getfileattr(DWORD *flags);
- int findfrst(ffbuf *b);
- int findnext(ffbuf *b);
- int findclse(ffbuf *b);
- void get(char path[]);
- void getf(char f[]);
- long getsize();
- long locatestr(char s[]);
- char *chkinc(abspath &x);
-
- static int gethftime(HANDLE h, SYSTEMTIME *ft);
- static int sethftime(HANDLE h, SYSTEMTIME &ft);
- };
-
- class conpath;
-
- class varpath:public abspath /* variable path */
- {
- public:
-
- virtual int set(char b[]) = 0;
-
- int tostd()
- {
- return abspath::tostd(this);
- }
- int setcwd();
- int gethome();
- int setroot(int drv);
- int setrootsl(int drv);
- int setdirwin();
- int setdirsys();
- int setbackup(abspath &path);
- int setfmt(char fmt[], ...);
- int merge(char d[], char f[]);
- int merge(abspath &d, abspath &f);
- int rplfile(char f[]);
- int rplfile(abspath &f);
- int setext(char newext[]);
- int setlastc(char c);
- int tmpindir(abspath &d, char prefix[]);
- int tmpinsamedir(abspath &path, char prefix[]);
- #ifdef WIN32
- int tolp();
- int tosp();
- int tolfn();
- int tosfn();
- int setdircom();
- #endif
- };
-
- class dynpath:public varpath /* variable path with dynamic buf */
- {
- dstring s;
-
- public:
-
- dynpath()
- {
-
- }
- dynpath(char b[])
- {
- set(b);
- }
- int set(char b[])
- {
- return s.set(b);
- }
- int set(int n)
- {
- return s.set(n);
- }
- int getlen()
- {
- return s.getlen();
- }
- char *getbuf()
- {
- return s;
- }
- };
-
- class borpath:public varpath /* variable path with borrowed buf */
- {
- char *s; /* the buffer must be large enough */
-
- public:
-
- borpath(char sx[])
- {
- s = sx;
- }
- int set(char b[])
- {
- strcpy(s, b);
-
- return 1;
- }
- char *getbuf()
- {
- return s;
- }
- };
-
- class stcpath:public varpath /* variable path with static buf */
- {
- char s[maxpath];
-
- public:
-
- stcpath()
- {
- s[0] = '\0';
- }
- stcpath(char b[])
- {
- set(b);
- }
- int set(char b[])
- {
- strcpy(s, b);
-
- return 1;
- }
- char *getbuf()
- {
- return s;
- }
- };
-
- class conpath:public abspath /* constant (invariable) path */
- {
- char *s;
-
- public:
-
- conpath(char b[])
- {
- s = b;
- }
- char *getbuf()
- {
- return s;
- }
- };
-